<?php


class zdFolderComponents extends sfComponents {
	
  	public function executeShow_folders() {
	
	
  	   if(!isset($this->module))
  	   {
  	   	 $this->module='catalog';
  	   }
        
        ////Выбираем  переданный каталог 
        // $c = new Criteria();    
        //$c->add(FolderPeer::TREE_LEFT, 1);
        //$c->addAnd(FolderPeer::ID, 3, Criteria::NOT_EQUAL);
        
        //$c->addAnd(FolderPeer::ID, 5, Criteria::NOT_EQUAL);
        //$c->addAscendingOrderByColumn(FolderPeer::TREE_LEFT);
        //$this->folders= FolderPeer::doSelect($c);
        //echo $this->folder_id;
  		if($this->folder_id)
  		{
  		$root = FolderPeer::retrieveByPK($this->folder_id);
  		$this->folders= $root->getChildren();
  		}
  		elseif($this->scope_id)
  		{
  		/*	
  		 $c = new Criteria();    
         $c->add(FolderPeer::SCOPE, $this->scope_id);       
  		 $this->folders= FolderPeer::doSelect($c);	
   */  		 
    
  		 $c = new Criteria();    
         $c->add(FolderPeer::SCOPE, $this->scope_id);
         $c->addAnd(FolderPeer::TREE_LEFT, 1);
  		 $root= FolderPeer::doSelectOne($c);	
  		 $this->folders= $root->getChildren();
          
  		}
  		
  		
  		//echo $this->folders;
  		
        ///Формируем и передаем массив запомненных каталогов      
        $cr = new Criteria();
        $cr -> add(RememberPeer::SESSION_ID,session_id());
        $cr->addAnd(RememberPeer::CLASS_NAME,'Folder');    
        $rem = RememberPeer::doSelect($cr);
        $ra = array();
        foreach ($rem as $r)
        {
        	$ra[$r->getId()] = $r->getItemId();
        }
        $this->rem = $ra;
	}
	
	public function executeOpen_folder() {
		
		$this->cur_f = FolderPeer::retrieveByPK ( $this->id );
		$this->folders = $this->cur_f->getChildren ();
		
	}

}
?>